<?php
namespace Rate\Controller;

use Todo\Controller\CurdController;
use Todo\Service\MessageService;

class ImportsController extends CurdController
{
    public function _before_imports()
    {
        $projectId = I('get.project_id/d');
        if (!$projectId) return;
        $Model = D('Todo/Rate/Project');
        $info = $Model->keyFind($projectId);
        if (!$info) return;

        $this->assign('project', $info);
        
        $normList = $Model->query("SELECT * FROM rate_norm WHERE way='2' AND tpl_id = ". $info['tpl_id']);
        $this->assign('normList', $normList);
    }

    public function edit()
    {
        $id = I('get.id');
        if(!$id) $this->error('非法请求!');
        $data = $this->_editData($id);
        $this->assign('data', $data);

        $project = D('Todo/Rate/Project')->keyFind($data['project_id']);
        $this->assign('project', $project);

        $norm = D('Todo/Rate/Norm')->keyFind($data['norm_id']);
        $this->assign('norm', $norm);

        $this->display();
    }

}